<?php
namespace app\index\model;
use think\Model;
use app\index\model\Order;
class Cart extends Model{

    public function get_order_sn()
    {
        $order_sn = null;
        // 保证不会有重复订单号存在
        while(true){
            $order_sn = date('YmdHis').rand(1000,9999); // 订单编号
            $o = new Order();
            $order_sn_count = $o->where("order_sn = ".$order_sn)->count();
            if($order_sn_count == 0)
                break;
        }

        return $order_sn;
    }
}